<template>
  <view class="my-account">
    <view class="bg-image">
      <image :src="tuiguang_bg" class="img" mode="aspectFill"></image>
      <view class="qrcode-img-wrapper">
        <rf-qrcode
          class="qrcode"
          cid="qrcode2229"
          makeOnLoad
          :size="160"
          :text="hostUrl"
        ></rf-qrcode>
      </view>
    </view>
    <view class="my-list">
      <view class="list-title flex">
        <view class="list-title-left"> 推广列表 </view>
        <view
          class="list-title-right flex"
          @tap="navTo('/pages/user/account/bill')"
        >
          查看全部
          <image :src="btn_enter" mode="aspectFill"></image>
        </view>
      </view>
      <view
        class="list-item flex-start"
        v-for="(item, index) in integralList"
        :key="index"
      >
        <image mode="aspectFill" :src="item.avatarUrl"></image>
        <view class="content-time">
          <view class="text"> {{ item.nickName }}</view>
          <view class="time"> {{ item.updated_at | time }}</view>
        </view>
      </view>
    </view>
    <rfLoading isFullScreen :active="loading"></rfLoading>
  </view>
</template>
<script>
import { inviteList } from "@/api/login";
import moment from "@/common/moment";
import rfQrcode from "@/components/rf-qrcode";
export default {
  components: { rfQrcode },
  data() {
    return {
      headImg: this.$mAssetsPath.headImg,
      loading: true,
      tuiguang_bg: this.$mAssetsPath.tuiguang_bg,
      btn_enter: this.$mAssetsPath.btn_enter_01,
      hostUrl: "",
      integralList: [],
    };
  },
  onLoad() {
    this.getinviteList();
    let user = uni.getStorageSync("userInfo");
    this.hostUrl = user.invite_link;
  },
  filters: {
    time(val) {
      return moment(val).format("YYYY-MM-DD HH:mm:ss");
    },
  },
  methods: {
    navTo(route) {
      this.$mRouter.push({ route });
    },
    async getinviteList() {
      await this.$http
        .get(inviteList, { page: 1 })
        .then((r) => {
          console.log(r);
          this.loading = false;
          r.data.data.forEach((item, index) => {
            if (index < 3) {
              this.integralList.push(item);
            }
          });
        })
        .catch(() => {});
    },
  },
};
</script>
<style scoped lang="scss">
page {
  background: #ffffff;
  .my-account {
    background: #ffffff;
    height: 100vh;
  }
  .bg-image {
    position: relative;
    .img {
      height: 718upx;
      width: 100%;
    }
    .qrcode-img-wrapper {
      position: absolute;
      bottom: 35upx;
      left: 179upx;
    }
  }
  .my-list {
    margin: 0 20upx;
    .list-title-left {
      font-size: 30upx;
      font-weight: bold;
      color: #333333;
    }
    .list-title-right {
      font-size: 24upx;
      font-family: PingFang SC;
      font-weight: 500;
      color: #999999;
      image {
        height: 28upx;
        width: 16upx;
        margin-left: 20upx;
      }
    }
    .list-item {
      height: 128upx;
      border-bottom: 1upx solid #eeeeee;
      image {
        height: 70upx;
        width: 70upx;
        border-radius: 50%;
      }
      .content-time {
        margin-left: 20upx;
        .text {
          font-size: 28upx;
          height: 40upx;
          line-height: 40upx;
          font-weight: 500;
        }
        .time {
          font-size: u24px;
          font-weight: 400;
          color: #999999;
        }
      }
    }
  }
}
</style>
